package config;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import service.HelloService;

/**
 * @description:
 * @author: lijinze
 * @createDate: 2020/7/28
 */
// 将配置属性注入到容器
@EnableConfigurationProperties(HelloProperties.class)
@Configuration
@ConditionalOnClass(HelloService.class)
public class HelloConfigurationProperties {
    @Autowired
    HelloProperties properties;

    @Bean
    public HelloService helloService() {
        HelloService service = new HelloService();
        service.setName(properties.getName());
        service.setDesc(properties.getDesc());
        return service;
    }


}
